package name.luoyong.shiro.shiroIniCustom.filter.print;

import java.io.IOException;
import java.util.Collection;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import name.luoyong.shiro.shiroIniCustom.filter.AbstractFilter;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.Subject;

public class PrintSession extends AbstractFilter {

	@Override
	protected void doFilter(HttpServletRequest request, HttpServletResponse response, FilterChain chain)
			throws IOException, ServletException {

		Subject subject = SecurityUtils.getSubject();
		Session session = subject.getSession();
		
		Collection<Object> keys = session.getAttributeKeys();
		
		if(keys != null) {
			System.out.println("------------- printSession ------------");
			for(Object key : keys) {
				Object value = session.getAttribute(key);
				System.out.println(key+" : "+value);
			}
			System.out.println("************ printSession  *************");
			System.out.println();
		}
		
		
		
	}

}
